package com.jt.www.enums.woxuebao;

import org.springframework.util.StringUtils;

/**
 * @author admin_ltf
 * @create 2019-06-01 16:59
 */

public enum ProNameToCodeEnum {

    Prod1("济宁学平险", "19PR979745"),
    Prod2("云南学平险", "19PR896371");

    private String prodName;
    private String prodCode;


    ProNameToCodeEnum(String prodName, String prodCode) {
        this.prodName = prodName;
        this.prodCode = prodCode;
    }

    public static String getproductCode(String prodName) {
        String prodCode = null;
        if (StringUtils.isEmpty(prodName)) {
            return prodCode;
        }
        for (ProNameToCodeEnum oldProdNameToNewEnum : ProNameToCodeEnum.values()) {
            if (prodName.equals(oldProdNameToNewEnum.prodName)) {
                prodCode = oldProdNameToNewEnum.prodCode;
                break;
            }
        }
        return prodCode;
    }

    public static String getproductName(String prodCode) {
        String prodName = null;
        if (StringUtils.isEmpty(prodCode)) {
            return prodName;
        }
        for (ProNameToCodeEnum oldProdNameToNewEnum : ProNameToCodeEnum.values()) {
            if (prodCode.equals(oldProdNameToNewEnum.prodCode)) {
                prodName = oldProdNameToNewEnum.prodName;
                break;
            }
        }
        return prodName;
    }

    public String getProdName() {
        return prodName;
    }

    public String getProdCode() {
        return prodCode;
    }
}
